﻿// The Nova Project by Ken Beckett.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php

using System.Collections.Generic;

using Nova.CodeDOM;

namespace Nova.UI
{
    /// <summary>
    /// The view model for a <see cref="CodeDOM.PragmaWarningDirective"/>.
    /// </summary>
    public class PragmaWarningDirectiveVM : PragmaDirectiveVM
    {
        #region /* STATICS */

        internal static void AddViewModelMapping()
        {
            CreateViewModel.Add(typeof(PragmaWarningDirective),
                delegate(CodeObject codeObject, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary) { return new PragmaWarningDirectiveVM((PragmaWarningDirective)codeObject, dictionary); });
        }

        #endregion

        #region /* CONSTRUCTORS */

        /// <summary>
        /// Create a view model instance for the specified <see cref="CodeDOM.PragmaWarningDirective"/>.
        /// </summary>
        public PragmaWarningDirectiveVM(PragmaWarningDirective pragmaWarningDirective, Dictionary<CodeObject, CodeObjectVM> dictionary)
            : base(pragmaWarningDirective, dictionary)
        { }

        #endregion

        #region /* PROPERTIES */

        /// <summary>
        /// The underlying <see cref="CodeDOM.PragmaWarningDirective"/> model.
        /// </summary>
        public PragmaWarningDirective PragmaWarningDirective
        {
            get { return (PragmaWarningDirective)CodeObject; }
        }

        #endregion

        #region /* METHODS */

        #endregion

        #region /* RENDERING */

        protected override void RenderArgument(CodeRenderer renderer, RenderFlags flags)
        {
            base.RenderArgument(renderer, flags);
            renderer.RenderText(" ", PUNC_BRUSH, this);
            renderer.RenderText(PragmaWarningDirective.PragmaWarningActionToString(PragmaWarningDirective.PragmaWarningAction), KEYWORD_BRUSH, this);
            if (PragmaWarningDirective.HasWarningNumbers)
            {
                renderer.RenderText(" ", PUNC_BRUSH, this);
                bool first = true;
                foreach (int number in PragmaWarningDirective.WarningNumbers)
                {
                    if (!first)
                        renderer.RenderText(PragmaWarningDirective.ParseTokenSeparator + " ", PUNC_BRUSH, this);
                    renderer.RenderText(number.ToString(), NUMERIC_BRUSH, this);
                    first = false;
                }
            }
        }

        #endregion
    }
}
